import { request } from "umi";

/** 获取患者信息列表 */
export async function getPatientList({ current, pageSize, ...params }: Partial<COMMON.PageParams & PATIENT.PatientInfo>) {
  return request<COMMON.PageResult<PATIENT.PatientInfo>>(`/api/patient/${current}/limit/${pageSize}`, {
    params,
    headers: {
      Action_Id: '900900000'
    }
  });
}

/** 新增患者信息 */
export async function addPatientInfo(data: Partial<PATIENT.PatientInfo>) {
  return request(`/api/patient/info`, {
    method: 'POST',
    data,
    headers: {
      Action_Id: '900900001'
    }
  });
}

/** 修改患者信息 */
export async function editPatientInfo({ record_id, ...data }: Partial<PATIENT.PatientInfo>) {
  return request(`/api/patient/${record_id}`, {
    method: 'PATCH',
    data,
    headers: {
      Action_Id: '900900003'
    }
  });
}

/** 删除患者信息 */
export async function deletePatientInfo(record_id: string) {
  return request(`/api/patient/${record_id}`, {
    method: 'DELETE',
    headers: {
      Action_Id: '900900004'
    }
  });
}


/** 查询患者订单历史记录 */
export async function getPatientOrderHistory({ current, pageSize, identity_no, patient_id }: Partial<COMMON.PageParams & { patient_id: string, identity_no: string }>) {
  return request<COMMON.PageResult<PATIENT.PatientInfo>>(`/api/order/page/${current}/limit/${pageSize}`, {
    method: 'POST',
    data: { identity_no, patient_id }
  });
}

/** 查询患者结算历史记录 */
export async function getPatientBillingHistory({ current, pageSize, patient_id }: Partial<COMMON.PageParams & { patient_id: string }>) {
  return request<COMMON.PageResult<PATIENT.PatientInfo>>(`/api/order/plan/bill/${current}/limit/${pageSize}`, {
    params: { patient_id }
  });
}
